<div class="form">
<FORM method="post" action="/backend/products/save/">
    <H1>{if $Products->isNew()}Добавление продукта{else}Редактирование продукта '{$Products->title}'{/if}</H1>
    <div class="operation">
    	<a href="{$fvConfig->get('dir_web_root')}news/" onclick="go('{$fvConfig->get('dir_web_root')}news/'); return false;" class="left">вернутся к списку</a>
    	<div style="clear: both;"></div>
    </div>
    <div style="width: 90%; float: left;">
    <fieldset>
        <legend>Общая информация</legend>
   		<table>
        	<tr>
        		<td><label for="title">Название:</label></td>
        		<td><input type="text" id="title" name="n[title]" value="{$Products->title|escape}"/></td>
        	</tr>
        	<tr>
        		<td><label for="price">Цена (за 100г):</label></td>
        		<td><input type="text" id="price" name="n[price]" value="{$Products->price|escape}"/></td>
        	</tr>
        	<tr>
        		<td><label for="country">Страна производитель:</label></td>
        		<td><input type="text" id="country" name="n[country]" value="{$Products->country|escape}"/></td>
        	</tr>
        	<tr>
        		<td><label for="artikul">Артикул:</label></td>
        		<td><input type="text" id="artikul" name="n[artikul]" value="{$Products->artikul|escape}"/></td>
        	</tr>
        	<tr>
        		<td colspan="2"><label for="description">Описание:</label>{$editor}</td>
        	</tr>
	    	</table>
    </fieldset>
    <div class="buttonpanel">
        <input type="submit" name="save" value="Сохранить" class="button"  onclick="$('redirect').value = '';">
        <input type="submit" name="save_and_return" value="Сохранить и выйти" class="button" onclick="$('redirect').value = '1';">
    </div>
    <input type="hidden" name="id" id="id" value="{$Products->getPk()}" />
    <input type="hidden" name="n[image]" id="image" value="{$Products.image}" />
    <input type="hidden" id="redirect" name="redirect" value="" />
    </div>
	<div style="float: left; margin-left: 10px;">
	</div>
<div style="clear: both;" />
</div>
</form>
<form method="post" action="{$fvConfig->get('dir_web_root')}products/uploadimage"  enctype="multipart/form-data" id="products_upload_form">
    <fieldset>
        <legend>Изображение</legend>

        <table class="form">
        <tr><td style="width: 1px;">
        <label for="type">Изображение товара</label></td><td>
            <input type="file" name="image" style="width:500px">
        </td><td>
            <input type="submit" name="save" value="загрузить" class="button">
        </td></tr>
        </table>
        
    </fieldset>
    <iframe name="products_upload_frame" id="products_upload_frame" src="javascript:void(0);" style="display: none;">
    </iframe>
    
	<div id="products_upload_preview" style="text-align: center; {if !$Products->hasFile('image', 'small')}display: none;{/if}">
    	{if $Products->hasFile('image', 'small')}
        	<img id="products_upload_img" {$Products->getImageSize('image', 'small')} style="border: 0px solid none;" src="{$Products->getImageDir(true)}{$Products->getImageName('image', 'small')}" /><br />
            <a href="javascript: void(0);" id="products_upload_delete" style="font-size: 12px; color: blue; text-decoration: underline;">удалить</a>
        {else}
        	<img id="products_upload_img" width="{$fvConfig->get('images.small.width')}" style="border: 0px none;" src="" /><br />
            <a href="javascript: void(0);" id="products_upload_delete" style="font-size: 12px; color: blue; text-decoration: underline;">удалить</a>
        {/if} 
    </div>
</form>
</div>
<script>
	new UploadPanel('products_upload', '{$fvConfig->get('dir_web_root')}products/deleteImage');
	{literal}
    Object.extend(window, {
        updateImage: function (imageName, width, height) {
            if ($('products_upload_img')) {
                $('products_upload_img').src = '{/literal}{$fvConfig->get('path.upload.web_tmp_dir')}{literal}' + imageName;
                $('products_upload_img').width = width;
                $('products_upload_img').height = height;
            }
            $('image').value = imageName;
            if (imageName != ''){
                $('products_upload_preview').show();
            }
            else 
                $('products_upload_preview').hide();
        }
    });

    {/literal}
</script>